Time synchronization method, apparatus, and system

ABSTRACT

In various embodiments, a method is provided. In this method, a first signal is received from a master node, and is sampled to obtain a first sample. The first sample is then quantized to obtain a quantized form of the first sample. A first synchronization sequence is detected from the quantized form of the first sample at T2. First information is received from the master node and the first information is used to indicate a moment T1 at which the master node sends the first synchronization sequence. A second synchronization sequence is sent to the master node at T3. Second information received from the master node and the second information is used to indicate a moment T4 at which the master node detects a quantized form of the second synchronization sequence. Time synchronization is performed based on T1, T2, T3, and T4.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No.PCT/CN2017/120075, filed on Dec. 29, 2017, the disclosure of which ishereby incorporated by reference in its entirety.

TECHNICAL FIELD

This application relates to the communications field, and in particular,to a time synchronization method, apparatus, and system.

BACKGROUND

A full name of the Institute of Electrical and Electronics Engineers(IEEE) 1588 protocol is “Standard for a Precision Clock SynchronizationProtocol for Networked Measurement and Control Systems”, which defines aPrecision Time Protocol (PTP). A basic function of the Precision TimeProtocol is to maintain synchronization between a most precise clock andother clocks in a distributed network. In actual application, IEEE 1588is a master-slave synchronization system. In a synchronization processof the system, a master node periodically releases a timesynchronization packet and timestamp information, a slave node obtainsthe related time synchronization packet and timestamp information byexchanging a packet with the master node, and calculates a line timedelay and a time difference between the master node and the slave node.The slave node then uses the time difference to adjust a local time, sothat a slave node time is consistent with a master node time.

With development of communications technologies, an increasingly strictrequirement is imposed on an offset of time synchronization between basestations in a communications scenario. For example, in a 5th Generation(5G) mobile communications network, an offset of time synchronizationbetween base stations is required to fall within 100 ns, imposing astrict requirement on time synchronization in an optical switchingnetwork. For example, a time synchronization precision loss caused by asingle-hop device needs to be controlled to fall within 5 ns. However,in an optical transport network at a metropolitan convergence layer, aphotonic integrated device (PID) scenario is usually used. In thisscenario, no dedicated optical supervisory channel (OSC) is used totransmit a 1588 time synchronization packet, and the 1588synchronization packet needs to be transmitted through an electricsupervisory channel (ESC). During transmission through the ESC channel,all time synchronization packet data needs to be forwarded by using aline-side optical module. As an optical module becomes more complex,delay uncertainty caused by the optical module is higher. For example,the delay uncertainty is usually above a magnitude of 10 ns, causing abottleneck to a 5G high-precision time synchronization technology.

SUMMARY

Various embodiments can provide a time synchronization method,apparatus, and system, to improve precision of time synchronization.

According to a first aspect, a time synchronization method is provided,including: receiving, by a slave node, a first signal from a masternode, where the first signal includes a first synchronization sequence;sampling, by the slave node, the first signal, to obtain a first sample;quantizing, by the slave node, the first sample, to obtain a quantizedform of the first sample; detecting, by the slave node, the firstsynchronization sequence from the quantized form of the first sample,where a moment of detecting the first synchronization sequence is T2;receiving, by the slave node, first information from the master node,where the first information is used to indicate a moment T1 at which themaster node sends the first synchronization sequence; sending, by theslave node, a second synchronization sequence to the master node, wherea moment of sending the second synchronization sequence is T3;receiving, by the slave node, second information from the master node,where the second information is used to indicate a moment T4 at whichthe master node detects a quantized form of the second synchronizationsequence; and performing, by the slave node, time synchronizationbetween the slave node and the master node based on T1, T2, T3, and T4.

In this embodiment, time synchronization is performed between the masternode and the slave node by sending the first synchronization sequenceand the second synchronization sequence, and the moments of receivingthe synchronization sequences are determined when the synchronizationsequences are in the quantized forms. Therefore, relatively few types ofsignal processing are performed on the synchronization sequences, sothat delay uncertainty caused by different signal processing can bereduced, thereby improving precision of time synchronization.

In an example implementation, the detecting, by the slave node, thefirst synchronization sequence from the quantized form of the firstsample includes: performing, by the slave node, correlation peakdetection of the first synchronization sequence on the quantized form ofthe first sample.

In an example implementation, the first signal further includes a thirdsynchronization sequence used for group synchronization, and a firstoffset exists between a first element of the third synchronizationsequence and a first element of the first synchronization sequence; andthe detecting, by the slave node, the first synchronization sequencefrom the quantized form of the first sample includes: determining, bythe slave node, a first location, where the first location is a locationof the first element of the third synchronization sequence in thequantized form of the first sample; determining, by the slave node, asecond location based on the first location and the first offset, wherethe second location is a location of the first element of the firstsynchronization sequence in the quantized form of the first sample;obtaining, by the slave node, a quantized form of a second sample basedon the second location, where the first sample includes the secondsample; and detecting, by the slave node, the first synchronizationsequence from the quantized form of the second sample.

In this embodiment, the first offset exists between the thirdsynchronization sequence used for group synchronization and the firstsynchronization sequence. Therefore, after determining the firstlocation of the third synchronization sequence in the quantized form ofthe first sample, the slave node may determine the second location ofthe first synchronization sequence based on the first offset, and obtainthe quantized form of the second sample based on the second location, toperform correlation peak detection of the first synchronizationsequence. This reduces an operation amount of correlation peakdetection, and improves efficiency of correlation peak detection,thereby improving efficiency of time synchronization between the masternode and the slave node.

In an example implementation, the determining, by the slave node, afirst location includes: performing, by the slave node, correlation peakdetection of the third synchronization sequence on the quantized form ofthe first sample, to determine the first location; and the detecting, bythe slave node, the first synchronization sequence from the quantizedform of the second sample includes: performing, by the slave node,correlation peak detection of the first synchronization sequence on thequantized form of the second sample.

In an example implementation, the sending, by the slave node, a secondsynchronization sequence to the master node includes: generating, by theslave node, an encoded codeword; inserting, by the slave node, thesecond synchronization sequence into the encoded codeword, where amoment of inserting the second synchronization sequence is T3;processing, by the slave node, the encoded codeword into which thesecond synchronization sequence is inserted, to generate a secondsignal; and sending, by the slave node, the second signal to the masternode.

In this embodiment, time synchronization is performed between the masternode and the slave node by sending the first synchronization sequenceand the second synchronization sequence, and T3 used for timesynchronization is a moment of inserting the second synchronizationsequence after encoding. Therefore, relatively few types of signalprocessing are performed on the second synchronization sequence beforethe second synchronization sequence is detected, so that delayuncertainty caused by different signal processing can be reduced,thereby improving precision of time synchronization.

In an example implementation, the slave node inserts, into the encodedcodeword, a fourth synchronization sequence used for groupsynchronization, where a second offset exists between a first element ofthe fourth synchronization sequence and a first element of the secondsynchronization sequence.

In this embodiment, the second offset exists between the fourthsynchronization sequence used for group synchronization and the secondsynchronization sequence. Therefore, after determining a third locationof the fourth synchronization sequence, the master node may extract,based on the second offset, a quantized form that is of a fourth sampleand in which the second synchronization sequence is located, to performcorrelation peak detection of the second synchronization sequence. Thisreduces an operation amount of correlation peak detection, and improvesefficiency of correlation peak detection, thereby improving efficiencyof time synchronization between the master node and the slave node.

In an example implementation, before the receiving, by a slave node, afirst signal from a master node, the method further includes: receiving,by the slave node, first primary synchronization information from themaster node, where the first primary synchronization information is usedto trigger the slave node to detect whether the signal received by theslave node from the master node includes the first synchronizationsequence.

In this embodiment, the master node sends the first primarysynchronization information to the slave node, to instruct the slavenode to trigger detection of the first synchronization sequence, so thatthe slave node may perform detection in a time window starting from amoment of receiving the first primary synchronization information,instead of continuously performing detection, thereby improvingefficiency of detecting the first synchronization sequence.

In an example implementation, before the sending, by the slave node, asecond synchronization sequence to the master node, the method furtherincludes: sending, by the slave node, first secondary synchronizationinformation to the master node, where the first secondarysynchronization information is used to trigger the master node to detectwhether the signal from the slave node includes the secondsynchronization sequence.

In this embodiment, the slave node sends the first secondarysynchronization information to the master node, to instruct the masternode to trigger detection of the second synchronization sequence, sothat the master node may perform detection in a time window startingfrom a moment of receiving the first secondary synchronizationinformation, instead of continuously performing detection, therebyimproving efficiency of detecting the second synchronization sequence.

In an example implementation, after the sending, by the slave node, asecond synchronization sequence to the master node, the method furtherincludes: sending, by the slave node, second secondary synchronizationinformation to the master node, where the second secondarysynchronization information is used to indicate that the slave node hassent the second synchronization sequence.

In this embodiment, the slave node sends the second secondarysynchronization information to the master node, to indicate that thesecond synchronization sequence has been sent. Therefore, afterreceiving the second secondary synchronization information, the masternode may stop detecting the second synchronization sequence. This canavoid a resource waste caused by continuously performing correlationpeak detection when the master node fails to detect the secondsynchronization sequence. Therefore, a protection mechanism exists whendetection of the second synchronization sequence fails, therebyimproving time synchronization efficiency.

In an example implementation, the receiving, by the slave node, secondinformation from the master node includes: when the master node detectsthe second synchronization sequence, receiving, by the slave node, thesecond information from the master node; and further includes: when themaster node detects no second synchronization sequence, receiving, bythe slave node, second primary synchronization information from themaster node, where the second primary synchronization information isused to indicate that the master node fails to detect the secondsynchronization sequence.

In this embodiment, when the master node fails to detect the secondsynchronization sequence, the master node sends the second primarysynchronization information to the slave node, to indicate thatdetection of the second synchronization sequence fails. Therefore, aprotection mechanism exists when detection of the second synchronizationsequence fails, so that the slave node discards invalid data, therebyimproving time synchronization efficiency.

According to a second aspect, a time synchronization method is provided,including: sending, by a master node, a first signal to a slave node,where the first signal includes a first synchronization sequence;sending, by the master node, first information to the slave node, wherethe first information is used to indicate a moment T1 at which themaster node sends the first synchronization sequence; receiving, by themaster node, a second signal from the slave node, where the secondsignal includes a second synchronization sequence; sampling, by themaster node, the second signal, to obtain a third sample; quantizing, bythe master node, the third sample, to obtain a quantized form of thethird sample; detecting, by the master node, the second synchronizationsequence from the quantized form of the third sample, where a moment ofdetecting the second synchronization sequence is T4; and sending, by themaster node, second information to the slave node, where the secondinformation is used to indicate T4, and T1 and T4 are used for timesynchronization between the master node and the slave node.

In this embodiment, time synchronization is performed between the masternode and the slave node by sending the first synchronization sequenceand the second synchronization sequence, and moments of receiving thesynchronization sequences are determined when the synchronizationsequences are in the quantized forms. Therefore, relatively few types ofsignal processing are performed on the synchronization sequences, sothat delay uncertainty caused by different signal processing can bereduced, thereby improving precision of time synchronization.

In an example implementation, the detecting, by the master node, thesecond synchronization sequence from the quantized form of the thirdsample includes: performing, by the master node, correlation peakdetection of the second synchronization sequence on the quantized formof the third sample.

In an example implementation, the second signal further includes afourth synchronization sequence used for group synchronization, and asecond offset exists between a first element of the fourthsynchronization sequence and a first element of the secondsynchronization sequence; and the detecting, by the master node, thesecond synchronization sequence from the quantized form of the thirdsample includes: determining, by the master node, a third location,where the third location is a location of the first element of thefourth synchronization sequence in the quantized form of the thirdsample; determining, by the master node, a fourth location based on thethird location and the second offset, where the fourth location is alocation of the first element of the second synchronization sequence inthe quantized form of the third sample; obtaining, by the master node, aquantized form of a fourth sample based on the fourth location, wherethe third sample includes the fourth sample; and detecting, by themaster node, the second synchronization sequence from the quantized formof the fourth sample.

In this embodiment, the second offset exists between the fourthsynchronization sequence used for group synchronization and the secondsynchronization sequence. Therefore, after determining the thirdlocation of the fourth synchronization sequence, the master node mayextract, based on the second offset, the quantized form that is of thefourth sample and in which the second synchronization sequence islocated, to perform correlation peak detection of the secondsynchronization sequence. This reduces an operation amount ofcorrelation peak detection, and improves efficiency of correlation peakdetection, thereby improving efficiency of time synchronization betweenthe master node and the slave node.

In an example implementation, the determining, by the master node, athird location includes: performing, by the master node, correlationpeak detection of the fourth synchronization sequence on the quantizedform of the third sample, to determine the third location; and thedetecting, by the master node, the second synchronization sequence fromthe quantized form of the fourth sample includes:

performing, by the master node, correlation peak detection of the secondsynchronization sequence on the quantized form of the fourth sample.

In an example implementation, the sending, by a master node, a firstsignal to a slave node includes: generating, by the master node, anencoded codeword; inserting, by the master node, the firstsynchronization sequence into the encoded codeword, where a moment ofinserting the first synchronization sequence is T1; processing, by themaster node, the encoded codeword into which the first synchronizationsequence is inserted, to generate the first signal; and sending, by themaster node, the first signal to the slave node.

In an example implementation, the method further includes: inserting, bythe master node into the encoded codeword, a third synchronizationsequence used for group synchronization, where a first offset existsbetween a first element of the third synchronization sequence and afirst element of the first synchronization sequence.

In this embodiment, the first offset exists between the thirdsynchronization sequence used for group synchronization and the firstsynchronization sequence. Therefore, after determining the firstlocation of the third synchronization sequence in the quantized form ofthe first sample, the slave node may determine the second location ofthe first synchronization sequence based on the first offset, and obtainthe quantized form of the second sample based on the second location, toperform correlation peak detection of the first synchronizationsequence. This reduces an operation amount of correlation peakdetection, and improves efficiency of correlation peak detection,thereby improving efficiency of time synchronization between the masternode and the slave node.

In an example implementation, before the sending, by a master node, afirst signal to a slave node, the method further includes: sending, bythe master node, first primary synchronization information to the slavenode, where the first primary synchronization information is used totrigger the slave node to detect whether the signal received by theslave node from the master node includes the first synchronizationsequence.

In this embodiment, the master node sends the first primarysynchronization information to the slave node, to instruct the slavenode to trigger detection of the first synchronization sequence, so thatthe slave node may perform detection in a time window starting from amoment of receiving the first primary synchronization information,instead of continuously performing detection, thereby improvingefficiency of detecting the first synchronization sequence.

In an example implementation, before the receiving, by the master node,a second signal from the slave node, the method further includes:receiving, by the master node, first secondary synchronizationinformation from the slave node, where the first secondarysynchronization information is used to trigger the master node to detectwhether the signal from the slave node includes the secondsynchronization sequence.

In this embodiment, the slave node sends the first secondarysynchronization information to the master node, to instruct the masternode to trigger detection of the second synchronization sequence, sothat the master node may perform detection in a time window startingfrom a moment of receiving the first secondary synchronizationinformation, instead of continuously performing detection, therebyimproving efficiency of detecting the second synchronization sequence.

In an example implementation, after the receiving, by the master node, asecond signal from the slave node, the method further includes:receiving, by the master node, second secondary synchronizationinformation from the slave node, where the second secondarysynchronization information is used to indicate that the slave node hassent the second synchronization sequence.

In this embodiment, the slave node sends the second secondarysynchronization information to the master node, to indicate that thesecond synchronization sequence has been sent. Therefore, afterreceiving the second secondary synchronization information, the masternode may stop detecting the second synchronization sequence. This canavoid a resource waste caused by continuously performing correlationpeak detection when the master node fails to detect the secondsynchronization sequence. Therefore, a protection mechanism exists whendetection of the second synchronization sequence fails, improving timesynchronization efficiency.

In an example implementation, the sending, by the master node, secondinformation to the slave node includes: when the master node detects thesecond synchronization sequence, sending, by the master node, the secondinformation to the slave node; and further includes: when the masternode detects no second synchronization sequence, sending, by the masternode, second primary synchronization information to the slave node,where the second primary synchronization information is used to indicatethat the master node fails to detect the second synchronizationsequence.

In this embodiment, when the master node fails to detect the secondsynchronization sequence, the master node sends the second primarysynchronization information to the slave node, to indicate thatdetection of the second synchronization sequence fails. Therefore, aprotection mechanism exists when detection of the second synchronizationsequence fails, so that the slave node discards invalid data, therebyimproving time synchronization efficiency.

According to a third aspect, a node is provided, where the node isconfigured to perform the method implemented by a slave node in any oneof the first aspect or the possible implementations of the first aspect.Specifically, the node includes a module configured to perform themethod in any one of the first aspect or the possible implementations ofthe first aspect.

According to a fourth aspect, a node is provided, where the node isconfigured to perform the method implemented by a master node in any oneof the second aspect or the possible implementations of the secondaspect. Specifically, the node includes a module configured to performthe method in any one of the second aspect or the possibleimplementations of the second aspect.

According to a fifth aspect, a node is provided, where the node includesa communications interface, a memory, a processor, and a bus system. Thecommunications interface, the memory, and the processor are connected byusing the bus system. The memory is configured to store an instruction.The processor is configured to execute the instruction stored in thememory, to control the communications interface to receive a signaland/or send a signal. In addition, when the processor executes theinstruction stored in the memory, the processor can perform the methodperformed by a slave node in any one of the first aspect or the possibleimplementations of the first aspect.

According to a sixth aspect, a node is provided, where the node includesa communications interface, a memory, a processor, and a bus system. Thecommunications interface, the memory, and the processor are connected byusing the bus system. The memory is configured to store an instruction.The processor is configured to execute the instruction stored in thememory, to control the communications interface to receive a signaland/or send a signal. In addition, when the processor executes theinstruction stored in the memory, the processor can perform the methodperformed by a master node in any one of the second aspect or thepossible implementations of the second aspect.

According to a seventh aspect, a master-slave synchronization system isprovided, where the system includes the nodes in the third aspect andthe fourth aspect, or the system includes the nodes in the fifth aspectand the sixth aspect.

According to an eighth aspect, a computer readable medium is provided,and is configured to store a computer program, and the computer programincludes an instruction used to perform the method in any one of thefirst aspect or the possible implementations of the first aspect.

According to a ninth aspect, a computer readable medium is provided, andis configured to store a computer program, and the computer programincludes an instruction used to perform the method in any one of thesecond aspect or the possible implementations of the second aspect.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram of a process of time synchronizationbetween a master node and a slave node in a related technology;

FIG. 2 is a schematic diagram of an application environment according toan embodiment of this application;

FIG. 3 is a schematic diagram of an internal structure of an opticalmodule in a related technology;

FIG. 4 is a schematic diagram of an internal structure of an opticalmodule according to an embodiment of this application;

FIG. 5 is a schematic diagram of a frame of inserting a synchronizationsequence according to an embodiment of this application;

FIG. 6 is a schematic diagram of detecting a synchronization sequenceaccording to an embodiment of this application;

FIG. 7 is a schematic flowchart of a time synchronization methodaccording to an embodiment of this application;

FIG. 8 is a schematic flowchart of a time synchronization methodaccording to another embodiment of this application;

FIG. 9 is a schematic structural diagram of a node according to anembodiment of this application;

FIG. 10 is a schematic structural diagram of a node according to anotherembodiment of this application;

FIG. 11 is a schematic structural diagram of a node according to stillanother embodiment of this application; and

FIG. 12 is a schematic structural diagram of a node according to yetanother embodiment of this application.

DESCRIPTION OF EMBODIMENTS

The technical solutions of the embodiments in accordance with thedisclosure may be applied to various communications systems, such as: anoptical communications system, a Global System for Mobile Communications(GSM), a Code Division Multiple Access (CDMA) system, a Wideband CodeDivision Multiple Access (WCDMA) system, a general packet radio service(GPRS), a Long Term Evolution (LTE) system, an LTE frequency divisionduplex (FDD) system, an LTE time division duplex (TDD) system, aUniversal Mobile Telecommunications System (UMTS), a WorldwideInteroperability for Microwave Access (WiMAX) communications system, afuture 5th Generation (5G) system, or a New Radio (NR) system.

A node (for example, a master node or a slave node) in variousembodiments in accordance with the disclosure may be a device used forcommunicating with a terminal device. The node may be a base transceiverstation (BTS) in the Global System for Mobile Communications (GSM) orthe Code Division Multiple Access (CDMA) system, or may be a NodeB (NB)in the Wideband Code Division Multiple Access (WCDMA) system, or may bean evolved NodeB (eNB or eNodeB) in the LTE system, or may be a radiocontroller in a cloud radio access network (CRAN) scenario; or thenetwork device may be a relay station, an access point, an in-vehicledevice, a wearable device, a network device in a future 5G network, anetwork device in a future evolved PLMN network, or the like. This isnot limited in the embodiments of this application.

The following describes the technical solutions in accordance with thedisclosure with reference to accompanying drawings.

For ease of understanding, the following describes concepts of someterms used in this application.

Optical module: A function of the optical module isoptical-to-electrical conversion. After processing data, a transmit endconverts an electrical signal into an optical signal, and after theoptical signal is transmitted by using an optical fiber, a receive endconverts the optical signal into an electrical signal, and performslossless restoration on the data.

Serializer/deserializer (serdes, SDS): is a module used forserial/parallel conversion.

Framer/deframer (FRM): a frame mapping/demapping module in an opticalmodule. The framer/deframer can map a constant bit rate (constant bitrate, CBR) service to an optical channel transport unit (OTU) service.

Transmission digital signal processor (Tx DSP): a digital signalprocessing module in a sending direction, configured to preprocess ato-be-sent signal, for example, perform channel equalization, or performnoise reduction processing on the to-be-sent signal.

Reception digital signal processor (Rx DSP): a digital signal processingmodule in a receiving direction, which may perform determining on areceived signal. Determining means determining a quantized digitalsignal as a binary digital signal. The received digital signal processormay further perform group synchronization on received signals. Duringdigital communication, generally, a specific quantity of elements form a“word” or “sentence”, to be specific, form a “group” to be transmitted.Group synchronization is to identify a start/end moment of a digitalinformation group (“word” or “sentence”), or to provide a “start” momentand an “end” moment of each group. Group synchronization is sometimesreferred to as frame synchronization. To implement groupsynchronization, some special code words may be inserted into a digitalinformation stream as a head/tail mark of each group. These special codewords may be a synchronization sequence used for group synchronization.An element is a basic signal unit that carries an information amount.For example, an element may be symbols that are used to represent abinary number and that have a same time interval.

Electrical-to-optical conversion (E/O) module: is configured to convertan electrical signal into an optical signal.

Optical-to-electrical conversion (O/E) module: configured to convert anoptical signal into an electrical signal.

Digital-to-analog conversion circuit (DAC): a digital signal processingmodule in a sending direction, configured to convert a digital signalinto an analog signal.

Analog-to-digital conversion circuit (ADC): a digital signal processingmodule in a receiving direction, configured to convert an analog signalinto a digital signal. The DAC may be configured to sample an inputanalog signal, to obtain a sample. The sample is then quantized toobtain a quantized form of the sample. The sample obtained throughsampling may be a digital signal that is discrete in time domain, andthe quantized form of the sample (or a quantized sample) may be adigital signal that is discrete in both time domain and amplitude.

First in first out (FIFO): used to buffer data.

Forward error correction (FEC): a data encoding technology, in which areceive end may be configured to verify a detection error intransmission. In an FEC manner, a receive end not only can discover anerror of data, but also can determine a location of an error occurringin a binary element, to correct the error.

Channel equalization: an anti-fading measure used to improvetransmission performance of a communications system in a fading channel.

Correlation peak: an autocorrelation operation performed on a segment ofsignal sequence. When signals overlap, autocorrelation energy ishighest, and an energy peak that is apparently different from those ofother locations can be seen.

Synchronization sequence used for group synchronization: a specificelement sequence, used for synchronization and channel estimation at areceive end.

FIG. 1 is a schematic diagram of a process of time synchronizationbetween a master node and a slave node in a related technology. Thefollowing first describes a synchronization process of the 1588 protocolin a related technology with reference to FIG. 1.

S101. A master node (Master) sends a first synchronization (sync) packetto a slave node (slave), and records a sending moment T1 into aregister.

S102. The slave node receives the first synchronization packet, andrecords a moment T2 of receiving the first synchronization packet.

S103. The master node sends a Follow_up packet to the slave node, wherethe “Follow_up” packet includes the moment T1.

S104. The slave node sends a Delay_ReqDelay packet to the master node,and records a moment T3 of sending the Delay_Req packet.

S105. The master node receives the Delay_Req packet, and records amoment T4 of receiving the Delay_Req packet.

S106. The master node sends a Delay_RespDelay packet to the slave node,where the Delay_Resp packet includes T4.

S107. The slave node may calculate a delayDelay and a time offsetbetween the master node and the slave node based on T1 to T4. Acalculation formula is as follows:

$\begin{matrix}{{Delay} = \frac{( {{T2} - {T1}} ) + ( {{T4} - {T3}} )}{2}} & (1) \\{{Offset} = \frac{( {{T2} - {T1}} ) - ( {{T4} - {T3}} )}{2}} & (2)\end{matrix}$

Delay is used to represent a delay, and the delay represents a delaytime caused in network transmission. Offset is used to indicate anoffset, and the offset represents a time difference between a slaveclock and a master clock.

The slave node may adjust a clock of the slave node based on acalculated delay and offset, to synchronize the clock with that of themaster node.

The following describes an application environment of this embodimentwith reference to FIG. 2. FIG. 2 shows a module through which a signalused for time synchronization between the master node and the slave nodepasses. As shown in FIG. 2, on a master node side, a signal istransmitted to an optical fiber after passing through a system clockmodule, a service board, and an optical module, and is then sent to theslave node. After the slave node receives the signal by using theoptical fiber, the signal passes through an optical module and a serviceboard, and then arrives at a system clock module.

The service board may also be referred to as a line card, and may beconfigured to generate a time synchronization pulse signal, and performtimestamping and protocol processing.

The system clock module may be a clock of a network element device, andis configured to provide synchronization timing and time information forall service boards on the network element device. The system clockmodule may be configured to implement timestamp calculation, filtering,and adjustment. For example, the network element device may be the nodein this embodiment.

A line-side optical module is equivalent to a service line, andintroduces a delay during time synchronization. In a related technology,an optical module can support only a delay report function. The opticalmodule may read a location of an FIFO waterline inside the opticalmodule to calculate uplink and downlink delays. However, precision isrelatively low in this manner. For example, in the related technology,precision of only about 20 ns can be implemented.

FIG. 3 is a schematic diagram of an internal structure of an opticalmodule 30 in the related technology. FIG. 3 shows paths through which anoptical channel transport unit (OTU) service passes in a sendingdirection and a receiving direction. A side of an SDS module isconnected to a service board, and a side of an electrical-to-opticalconversion (E/O) module or an optical-to-electrical conversion (O/E)module is connected to an optical fiber.

In an optical transport network, an OTU represents a framed opticalchannel data information structure. The OTU may include a data payloadarea and an overhead area. Alternatively, an OTUx may be used torepresent a framed optical channel data information structure, xrepresents an order of an OTU service, and a higher order indicates ahigher rate. Packets and data sent in the optical transport network maybe carried over the OUT for transmission.

In the sending direction, the OTU service passes through the SDS module,an FRM module, an FEC module, a Tx DSP module, a digital-to-analogconversion circuit (DAC), and an E/O module. The SDS module and the FRMbelong to a service layer. The FEC module, the Tx DSP module, the DAC,and the E/O module belong to a channel layer. Specifically, a service ona DAC line card is sent to the optical module by passing through theSDS. Inside the optical module, the FRM implements OTUx service framingdetection, and then channel FEC encoding is performed, and channelequalization algorithm processing is performed in the Tx DSP. Theservice passes through the DAC, and is converted by the E/O module intoan optical signal, and is sent to the optical fiber.

In the receiving direction, the OTU service successively passes an O/Emodule, an ADC, an Rx DSP module, an FEC module, an FRM module and anSDS module. The SDS module and the FRM belong to the service layer. TheFEC module, the Rx DSP module, the ADC, and the O/E module belong to thechannel layer. Specifically, the O/E module and the ADC collect andobtain line sample data, and after the Rx DSP performs channelequalization algorithm processing, FEC error correction is performed, toimplement lossless reception of the service, and then the data is sentto the service board by using the SDS after FRM framing.

According to the foregoing descriptions, in the related technology, theuplink and downlink delays are calculated by reading the location of theFIFO waterline inside the optical module. During signal processing, theFIFO is located in a position at an upper layer of the FEC, that is,located in a position at the service layer. For example, at a receiveend, after a time synchronization packet is received from the opticalfiber, the signal needs to be processed by a plurality of modules beforea delay can be reported. A time synchronization method in the 1588protocol is based on an ideal condition: Signals in a sending directionand a receiving direction are processed at a same moment inside a node.However, in actual application, processing moments of a plurality ofsignal processing modules through which the signal passes in the sendingdirection and the receiving direction have an error, and delayuncertainty is caused, affecting precision of time synchronizationbetween a master node and a slave node. In addition, more processingmodules through which the signal passes lead to larger delay uncertaintyand lower precision of time synchronization.

An embodiment in accordance with the disclosure provides a timesynchronization method. A main idea of the time synchronization methodis to add a synchronization sequence used for time synchronization to asignal sent by a master/slave node, and to detect the synchronizationsequence when a received signal is in a quantized form, to determine amoment for time synchronization. In this way, time synchronization canbe implemented at a lower layer during signal processing, therebyreducing delay uncertainty and improving precision of timesynchronization.

In one embodiment, a synchronization sequence used for timesynchronization may be added to a signal of a transmit end, and areceive end may perform synchronization and timestamping throughcorrelation peak detection of the synchronization sequence. In addition,the service layer implements a process of time synchronization betweenthe master node and the slave node based on a time stamp and analgorithm. The foregoing transmit end may be a master node, theforegoing receive end may be a slave node, and the foregoingsynchronization sequence may replace the first synchronization packet inS101 in FIG. 1. Alternatively, the foregoing transmit end may be a slavenode, the foregoing receive end may also be a slave node, and theforegoing synchronization sequence may replace the Delay_Req packet inS105 in FIG. 1.

The transmit end may add the synchronization sequence used for timesynchronization to an encoded codeword that is obtained through encoding(for example, after FEC is performed). Then processing may be performedbased on the encoded codeword to which the synchronization sequence isadded, to generate a signal, and send the signal to the receive end. Theforegoing processing may include, for example, preprocessing,analog-to-digital conversion, and E/O conversion on the encodedcodeword. The receive end may detect a quantized form of thesynchronization sequence, to determine a moment of receiving thesynchronization sequence. The synchronization sequence is inserted afterbeing encoded on a transmit end side, and timestamping is performedbefore encoding on a receive end side. Therefore, time synchronizationcan be implemented at a lower layer during signal processing. Becausefewer types of processing are performed on the signal before thequantized form of the synchronization sequence is detected, delayuncertainty is reduced, thereby improving precision of timesynchronization.

In addition, the foregoing synchronization sequence may also be referredto as a training sequence. A synchronization sequence is an elementsequence, and may be used for time synchronization or channel estimationat the receive end. A synchronization sequence has high correlationoperation orthogonality. To be specific, the synchronization sequencehas extremely strong autocorrelation energy, but very low energy ofco-correlation with any other signal. In addition, the synchronizationsequence can still maintain the foregoing features relatively well afterchannel link noise is superposed. With this characteristic, asynchronization sequence insertion point can be searched for at thereceive end by using a correlation operation, that is, timesynchronization can be implemented. Synchronization sequence detectionby using the foregoing correlation operation may also be referred to ascorrelation peak detection. The foregoing correlation operation is atime-domain signal convolution. A convolution formula is shown asfollows:

$\begin{matrix}{{{c(n)} = {\sum\limits_{k = 0}^{n}{{a(k)}{b( {n - k} )}}}},{n = {0 \sim ( {{n\; 1} + {n\; 2}} )}}} & (3)\end{matrix}$

c(n) represents a convolved sequence, a(k) represents a convolutionsequence a, b(n-k) represents a deconvolution of a convolution sequenceb, n represents a subscript serial number of a convolution sequenceresult, k represents a subscript serial number of a convolution sequenceoperation, n1 represents a length of the convolution sequence a, and n2represents a length of the convolution sequence b.

FIG. 4 is a structural diagram of an optical module 40 according to thisembodiment. As shown in FIG. 4, to implement the time synchronizationmethod in this embodiment, the optical module 40 further includes thefollowing modules:

(1) Optical module time synchronization protocol and algorithm (oTSPA)module: also referred to as an auto-negotiation protocol algorithmmodule. The oTSPA module is a state machine that is responsible forprocessing a synchronization sequence received or sent by an opticalmodule, and is configured to implement transmission of a timesynchronization signal, and ensure normal transmission of the timesynchronization signal by using a specific handshake protocol. The oTSPAmodule may receive and process a timestamp packet sent by a real timecounter (RTC), and insert the timestamp packet into OTU overheads; orplace a timestamp packet generated in a synchronization sequence at thechannel layer in service layer overheads for transmission. Further, theoTSPA may drive a transmit end synchronization sequence insertion moduleto insert the synchronization sequence used for time synchronization.The oTSPA may also drive a receive end synchronization sequenceidentification module to detect the synchronization sequence used fortime synchronization.

(2) Transmit end synchronization sequence insertion module: inserts,driven by the auto-negotiation protocol algorithm, the synchronizationsequence used for time synchronization, and generates a pulse signalcorresponding to the synchronization sequence and sends the pulse signalto the RTC for timestamping. As shown in FIG. 4, after an encodedcodeword passes through the transmit end synchronization sequenceinsertion module, the synchronization sequence used for timesynchronization may be inserted into the encoded codeword. In someembodiments, the synchronization sequence used for time synchronizationmay be inserted into the encoded codeword together with asynchronization sequence used for group synchronization.

In some embodiments, when a time synchronization request is initiated,the synchronization sequence used for time synchronization may beinserted into a fixed location following the synchronization sequenceused for group synchronization. In addition, a corresponding pulsesignal is generated when the synchronization sequence used for timesynchronization is inserted, and the pulse signal is sent to the RTC fortimestamping. For example, FIG. 5 is a schematic diagram of inserting,into an encoded codeword of the transmit end, a synchronization sequenceused for time synchronization. As shown in FIG. 5, when a timesynchronization request needs to be initiated, the synchronizationsequence used for time synchronization may be inserted into a fixedlocation following a synchronization sequence used for groupsynchronization. Therefore, a location of the synchronization sequenceused for time synchronization may be obtained by using an offsetlocation of the synchronization sequence used for group synchronization.A correlation operation of correlation peak detection is performed ononly one data block extracted from the synchronization sequence used fortime synchronization, so that operation complexity can be reduced. Insome embodiments, when the time synchronization request is initiated,the synchronization sequence may be inserted into the fixed location, orwhen no time synchronization request is initiated, an overhead sectioncorresponding to the fixed location may be used to send a random code.

In some embodiments, the transmit end may spare one time synchronizationsequence overhead location at an interval of a fixed time unit, toensure transmission bandwidth utilization.

In some embodiments, in some embodiments, there may be no locationassociation relationship between a synchronization sequence used fortime synchronization and a synchronization sequence used for groupsynchronization.

(3) Receive end synchronization sequence identification module:configured to identify a synchronization sequence in data through acorrelation operation, generate a corresponding pulse signal, and sendthe pulse signal to the RTC for timestamping.

For example, FIG. 6 is a schematic diagram of a process in which thereceive end performs correlation peak detection of a synchronizationsequence. The receive end may perform correlation peak detection on adata block obtained after ADC sampling and serial/parallel conversion,and when a synchronization sequence used for time synchronization isdetected, generate a corresponding pulse signal, and send the pulsesignal to the RTC for timestamping. In some embodiments, the receive endmay first perform correlation peak detection of a synchronizationsequence used for group synchronization, to determine a location of thesynchronization sequence used for group synchronization, and determine alocation of the synchronization sequence used for time synchronizationbased on the location of the synchronization sequence used for groupsynchronization. The receive end may extract, based on the location ofthe synchronization sequence used for time synchronization, a datasegment in the location, and then perform correlation peak detection onthe extracted data segment, and at a moment of detecting thesynchronization sequence used for time synchronization, generate acorresponding pulse signal, and send the pulse signal to the RTC fortimestamping.

(4) Real time counter (RTC): configured to generate a timestamp based ona received pulse signal, and send the timestamp to the oTSPA module.

The following describes a time synchronization method 700 according toan embodiment in accordance with reference to FIG. 7. The method 700 maybe performed by a master node and a slave node. As shown in FIG. 7, themethod 700 includes the following steps.

S701. The master node sends a first signal to the slave node, where thefirst signal includes a first synchronization sequence, andcorrespondingly, the slave node receives the first signal from themaster node, where a moment at which the master node inserts the firstsynchronization sequence into an encoded codeword corresponding to thefirst signal is T1, and a moment at which the slave node detects thefirst synchronization sequence is T2.

For example, the slave node samples the first signal to obtain a firstsample, quantizes the first sample to obtain a quantized form of thefirst sample, and detects the first synchronization sequence from thequantized form of the first sample. The moment of detecting the firstsynchronization sequence is T2.

A function of the foregoing first synchronization sequence may besimilar to that of the first synchronization packet in FIG. 1. Themaster node needs to record the moment T1 of sending the firstsynchronization sequence, and sends T1 to the slave node in subsequentinteraction. The slave node needs to record the moment T2 of receivingthe first synchronization sequence. T1 and T2 are used for timesynchronization between the master node and the slave node.

In some embodiments, the slave node detects the first synchronizationsequence from the quantized form of the first sample in two manners. Ina first manner, the slave node directly performs correlation peakdetection of the first synchronization sequence on the quantized form ofthe first sample. In a second manner, the first signal further includesa third synchronization sequence used for group synchronization, and afirst offset exists between a first element of the third synchronizationsequence and a first element of the first synchronization sequence; andthe detecting, by the slave node, the first synchronization sequencefrom the quantized form of the first sample includes: determining, bythe slave node, a first location, where the first location is a locationof the first element of the third synchronization sequence in thequantized form of the first sample; determining, by the slave node, asecond location based on the first location and the first offset, wherethe second location is a location of the first element of the firstsynchronization sequence in the quantized form of the first sample;obtaining, by the slave node, a quantized form of a second sample basedon the second location, where the first sample includes the secondsample; and detecting, by the slave node, the first synchronizationsequence from the quantized form of the second sample.

The determining, by the slave node, a first location includes:performing, by the slave node, correlation peak detection of the thirdsynchronization sequence on the quantized form of the first sample, todetermine the first location; and the detecting, by the slave node, thefirst synchronization sequence from the quantized form of the secondsample includes: performing, by the slave node, correlation peakdetection of the first synchronization sequence on the quantized form ofthe second sample.

In this embodiment, the first offset exists between the thirdsynchronization sequence used for group synchronization and the firstsynchronization sequence. Therefore, after determining the firstlocation of the third synchronization sequence in the quantized form ofthe first sample, the slave node may determine the second location ofthe first synchronization sequence based on the first offset, and obtainthe quantized form of the second sample based on the second location, toperform correlation peak detection of the first synchronizationsequence. This reduces an operation amount of correlation peakdetection, and improves efficiency of correlation peak detection,thereby improving efficiency of time synchronization between the masternode and the slave node.

The slave node may generate a pulse signal corresponding to T2 andperform timestamping at the moment of detecting the firstsynchronization sequence. For a specific process of generating the pulsesignal corresponding to T2 and performing timestamping, refer to contentof the receive end synchronization sequence identification module inFIG. 4.

Both the quantized form of the first sample and the quantized form ofthe second sample are digital signals before a binary digital signal isgenerated. In other words, the foregoing quantized form is a signaldiscrete in both time and amplitude. For example, the quantized form ofthe first sample may be a data block obtained before FEC processing isperformed.

S702. The master node sends first information to the slave node, wherethe first information is used to indicate a moment T1 at which themaster node sends the first synchronization sequence, andcorrespondingly, the slave node receives the first information from themaster node.

In some embodiments, a function of the first information is similar tothat of the Follow_up packet in FIG. 1. The first information may alsobe carried in a packet.

In some embodiments, the master node may record T1. For example, thatthe master node sends the first synchronization sequence to the slavenode at the moment T1 includes: generating, by the master node, anencoded codeword; inserting, by the master node, the firstsynchronization sequence into the encoded codeword, where a moment ofinserting the first synchronization sequence is T1; processing, by themaster node, the encoded codeword into which the first synchronizationsequence is inserted, to generate the first signal; and sending, by themaster node, the first signal to the slave node. For example, the masternode may generate a pulse signal and perform timestamping when insertingthe first synchronization sequence, and a moment corresponding to thetimestamp is T1. For a specific process of generating the pulse signalcorresponding to T1 and performing timestamping, refer to contentrelated to the transmit end synchronization sequence insertion module inFIG. 4.

For example, the master node may insert the foregoing firstsynchronization sequence into an encoded codeword on which FECprocessing is performed, and generate a timestamp corresponding to T1.

S703. The slave node sends a second synchronization sequence to themaster node, where a moment of sending the second synchronizationsequence is T3, and correspondingly, the master node receives the secondsynchronization sequence from the slave node, where a moment at whichthe master node detects a quantized form of the second synchronizationsequence is T4.

A function of the foregoing second synchronization sequence may besimilar to that of the Delay_Req packet in FIG. 1. The slave node mayrecord T3, and the master node may record T4, and send T4 to the slavenode in subsequent interaction. T3 and T4 are also used for timesynchronization between the master node and the slave node.

In some embodiments, the slave node may record T3. In some embodiments,that the slave node sends a second synchronization sequence to themaster node includes: generating, by the slave node, an encodedcodeword; inserting, by the slave node, the second synchronizationsequence into the encoded codeword, where a moment of inserting thesecond synchronization sequence is T3; processing, by the slave node,the encoded codeword into which the second synchronization sequence isinserted, to generate a second signal; and sending, by the slave node,the second signal to the master node. For example, the slave node maygenerate a pulse signal and perform timestamping when inserting thesecond synchronization sequence, and a moment corresponding to thetimestamp is T3. For a specific process of generating the pulse signalcorresponding to T3 and performing timestamping, refer to contentrelated to the transmit end synchronization sequence insertion module inFIG. 4.

For example, the slave node may insert the foregoing firstsynchronization sequence into an encoded codeword on which FECprocessing is performed, and generate a timestamp corresponding to T3.

That the master node detects the second synchronization sequence from aquantized form of the third sample, where the moment of detecting thesecond synchronization sequence is T4 specifically includes: receiving,by the master node, the second signal from the slave node, where thesecond signal includes the second synchronization sequence; sampling, bythe master node, the second signal, to obtain the third sample;quantizing, by the master node, the third sample, to obtain thequantized form of the third sample; and detecting, by the master node,the second synchronization sequence from the quantized form of the thirdsample, where the moment of detecting the second synchronizationsequence is T4.

In some embodiments, the master node may detect the secondsynchronization sequence from the quantized form of the third sample intwo manners. In a first manner, the master node directly performscorrelation peak detection of the second synchronization sequence on thequantized form of the third sample. In a second manner, the secondsignal further includes a fourth synchronization sequence used for groupsynchronization, and a second offset exists between a first element ofthe fourth synchronization sequence and a first element of the secondsynchronization sequence; and the detecting, by the master node, thesecond synchronization sequence from the quantized form of the thirdsample includes: determining, by the master node, a third location,where the third location is a location of the first element of thefourth synchronization sequence in the quantized form of the thirdsample; determining, by the master node, a fourth location based on thethird location and the second offset, where the second location is alocation of the first element of the fourth synchronization sequence inthe quantized form of the third sample; obtaining, by the master node, aquantized form of a fourth sample based on the fourth location, wherethe third sample includes the fourth sample; and detecting, by themaster node, the second synchronization sequence from the quantized formof the fourth sample.

The determining, by the master node, a third location includes:performing, by the master node, correlation peak detection of the fourthsynchronization sequence on the quantized form of the third sample, todetermine the third location. The detecting, by the master node, thesecond synchronization sequence from the quantized form of the fourthsample includes: performing, by the master node, correlation peakdetection of the second synchronization sequence on the quantized formof the fourth sample.

In this embodiment, the second offset exists between the fourthsynchronization sequence used for group synchronization and the secondsynchronization sequence. Therefore, after determining the thirdlocation of the fourth synchronization sequence, the master node mayextract, based on the second offset, the quantized form that is of thefourth sample and in which the second synchronization sequence islocated, to perform correlation peak detection of the secondsynchronization sequence. This reduces an operation amount ofcorrelation peak detection, and improves efficiency of correlation peakdetection, thereby improving efficiency of time synchronization betweenthe master node and the slave node.

The master node may generate a pulse signal corresponding to T4 andperform timestamping at the moment of detecting the secondsynchronization sequence. For a specific process of generating the pulsesignal corresponding to T4 and performing timestamping, refer to contentof the receive end synchronization sequence identification module inFIG. 4.

S704. The master node sends second information to the slave node, wherethe second information is used to indicate T4, and correspondingly, theslave node receives the second information from the master node.

In some embodiments, a function of the second information is similar tothat of the Delay_Resp packet in FIG. 1. The second information may alsobe carried in a packet.

S705. The slave node performs time synchronization between the slavenode and the master node based on T1, T2, T3, and T4.

For example, the performing time synchronization between the slave nodeand the master node based on T1, T2, T3, and T4 may be: substituting, bythe slave node, T1, T2, T3, and T4 into the formula (1) and the formula(2) in FIG. 1, to calculate a delay and a time offset between the masternode and the slave node. The slave node may adjust a time of the slavenode based on the delay and the time offset.

In this embodiment, time synchronization is performed between the masternode and the slave node by sending the first synchronization sequenceand the second synchronization sequence. The moments T2 and T4 ofreceiving the synchronization sequences are determined when thesynchronization sequences are in the quantized forms, and the moments T1and T3 of sending the synchronization sequences are subsequent toencoding. In other words, the moments T1 and T3 of sending thesynchronization sequences are subsequent to encoding, and the moments T2and T4 of receiving the synchronization sequences are prior to decoding.Therefore, in the foregoing time intervals, or in other words, in aninterval from T1 to T2 and an interval from T3 to T4, relatively fewtypes of signal processing are performed on the synchronizationsequences, so that delay uncertainty caused by different signalprocessing can be reduced, thereby improving precision of timesynchronization.

In one solution of this embodiment, a synchronization sequence is usedto perform time synchronization. In this manner, the synchronizationsequence is detected at a channel layer, and it is possible that areceive end cannot correctly detect the synchronization sequence.Therefore, the following continues to describe the method 700, whichfurther includes a processing method upon a failure in detecting asynchronization sequence.

In some embodiments, before the master node sends the firstsynchronization sequence to the slave node, the method 700 furtherincludes: sending, by the master node, first primary synchronizationinformation to the slave node, where the first primary synchronizationinformation is used to trigger the slave node to detect whether thesignal received by the slave node from the master node includes thefirst synchronization sequence. Correspondingly, the slave node receivesthe first primary synchronization information from the master node.

For example, after receiving the first primary synchronizationinformation, the slave node starts correlation peak detection of thefirst synchronization sequence. If the slave node still detects no firstsynchronization sequence after receiving the first information, itindicates that the slave node fails to detect the first synchronizationsequence. The slave node stops detecting the first synchronizationsequence. In this case, the slave node considers T2 indicated by thefirst information as invalid data, and a new round of a timesynchronization process is performed between the master node and theslave node. In other words, the slave node performs correlation peakdetection of the first synchronization sequence in a time window betweena moment of receiving the first primary synchronization information anda moment of receiving the first information. If detection of the firstsynchronization sequence in the time window fails, it indicates thattime synchronization fails, and a new round of the time synchronizationprocess needs to be started. Therefore, a protection mechanism exitswhen detection of the first synchronization sequence fails, so that theslave node discards invalid data, thereby improving time synchronizationefficiency.

In this embodiment, the master node sends the first primarysynchronization information to the slave node, to instruct the slavenode to trigger detection of the first synchronization sequence, so thatthe slave node may perform detection in the time window starting fromthe moment of receiving the first primary synchronization information,instead of continuously performing detection, thereby improvingefficiency of detecting the first synchronization sequence.

In some embodiments, before the slave node sends the secondsynchronization sequence to the master node, the method 700 furtherincludes: sending, by the slave node, first secondary synchronizationinformation to the master node, where the first secondarysynchronization information is used to trigger the master node to detectwhether the signal from the slave node includes the secondsynchronization sequence.

Similar to the first primary synchronization information, the slave nodesends the first secondary synchronization information to the master nodebefore sending the second synchronization sequence, to trigger themaster node to detect the second synchronization sequence, so that themaster node does not need to continuously perform detection.

In some embodiments, after the slave node sends the secondsynchronization sequence to the master node, the method 700 furtherincludes: sending, by the slave node, second secondary synchronizationinformation to the master node, where the second secondarysynchronization information is used to indicate that the slave node hassent the second synchronization sequence.

In this embodiment, after receiving the first secondary synchronizationinformation, the master node starts correlation peak detection of thesecond synchronization sequence. If the master node still detects nosecond synchronization sequence after receiving the second secondarysynchronization information, it indicates that the master node fails todetect the second synchronization sequence. The master node stopsdetecting the second synchronization sequence. In this case, the masternode sends second primary synchronization information to the slave node,and the information is used to indicate that the master node fails todetect the second synchronization sequence, so that the slave nodeconsiders previously recorded T3 as invalid data. In other words, themaster node performs correlation peak detection of the secondsynchronization sequence in a time window between a moment of receivingthe first secondary synchronization information and a moment ofreceiving the second secondary synchronization information. If detectionof the second synchronization sequence in the time window fails, itindicates that time synchronization fails, and a new round of the timesynchronization process needs to be started. Therefore, a protectionmechanism exits when detection of the second synchronization sequencefails, so that the slave node discards invalid data, thereby improvingtime synchronization efficiency.

In this embodiment, the slave node sends the second secondarysynchronization information to the master node, to indicate that thesecond synchronization sequence has been sent. Therefore, afterreceiving the second secondary synchronization information, the masternode may stop detecting the second synchronization sequence. This canavoid a resource waste caused by continuously performing correlationpeak detection when the master node fails to detect the secondsynchronization sequence. Therefore, a protection mechanism exists whendetection of the second synchronization sequence fails, improving timesynchronization efficiency.

In an S704 part of the method 700, that the master node sends secondinformation to the slave node, or correspondingly, the slave nodereceives the second information from the master node includes: When themaster node successfully detects the second synchronization sequence,the master node sends the second information to the slave node, andcorrespondingly, the slave node receives the second information from themaster node. The method further includes: When the master node fails todetect the second synchronization sequence, the master node sends thesecond primary synchronization information to the slave node, where thesecond primary synchronization information is used to indicate that themaster node fails to detect the second synchronization sequence, andcorrespondingly, the slave node receives the second primarysynchronization information from the master node.

In this embodiment, when the master node fails to detect the secondsynchronization sequence, the master node sends the second primarysynchronization information to the slave node, to indicate thatdetection of the second synchronization sequence fails. Therefore, aprotection mechanism exists when detection of the second synchronizationsequence fails, so that the slave node discards invalid data, therebyimproving time synchronization efficiency.

The following describes one example embodiment in accordance with thedisclosure with reference to FIG. 8. FIG. 8 is a schematic diagram of aspecific process of a time synchronization request. As shown in FIG. 8,a method 800 includes the following steps.

S801. A master node sends first primary synchronization information to aslave node, and correspondingly, the slave node receives the firstprimary synchronization information.

For a function and definition of the first primary synchronizationinformation, refer to related descriptions in FIG. 7, and details arenot described herein again.

In some embodiments, after receiving the first primary synchronizationinformation, the slave node may start correlation peak detection of afirst synchronization sequence.

In some embodiments, an oSTPA of the master node may send the firstprimary synchronization information, and after receiving the firstprimary synchronization information, an oSTPA of the slave node triggerscorrelation peak detection of the first synchronization sequence.

S802. The master node sends a first synchronization sequence to theslave node, and records a moment T1 of sending the first synchronizationsequence, and correspondingly, the slave node receives the firstsynchronization sequence from the master node, and records a moment T2of receiving the first synchronization sequence.

In some embodiments, the master node may insert the firstsynchronization sequence into a to-be-sent first signal, and the slavenode may detect the first synchronization sequence by using acorrelation peak detection function.

For example implementation of inserting, by the master node, the firstsynchronization sequence into an encoded codeword corresponding to thefirst signal and a specific process of detecting the first timesynchronization training by the slave node, refer to relateddescriptions in FIG. 4 to FIG. 7, and details are not described hereinagain.

S803. The master node sends first information to the slave node, wherethe first information is used to indicate the moment T1, andcorrespondingly, the slave node receives the first information, andobtains the moment T1.

In some embodiments, the first information may be carried in a packet.

In some embodiments, if the slave node still detects no firstsynchronization sequence after receiving the first information, itindicates that the slave node fails to detect the first synchronizationsequence. Therefore, the slave node considers the moment T1 indicated bythe first information as invalid data, and discards a current round of atime synchronization operation.

S804. The slave node sends first secondary synchronization informationto the master node, and correspondingly, the master node receives thefirst secondary synchronization information.

For a function and definition of the first secondary synchronizationinformation, refer to related descriptions in FIG. 7, and details arenot described herein again.

In some embodiments, after receiving the first secondary synchronizationinformation, the master node may start correlation peak detection of asecond synchronization sequence.

S805. The slave node sends a second synchronization sequence to themaster node, and records a sending moment T3, and correspondingly, themaster node receives the second synchronization sequence, and records areceiving moment T4.

In some embodiments, the slave node may insert the secondsynchronization sequence into a to-be-sent second signal, and the masternode may detect the second synchronization sequence by using acorrelation peak detection function.

For example implementation of inserting, by the slave node, the secondsynchronization sequence into an encoded codeword corresponding to thesecond signal and a specific process of detecting the second timesynchronization training by the master node, refer to relateddescriptions in FIG. 4 to FIG. 7, and details are not described hereinagain.

S806. After sending the second synchronization sequence, the slave nodesends second secondary synchronization information to the master node,and correspondingly, the master node receives the second secondarysynchronization information.

In some embodiments, if the master node still detects no secondsynchronization sequence after receiving the second secondarysynchronization information, it indicates that the master node fails todetect the second synchronization sequence.

S807. If the master node successfully detects the second synchronizationsequence, the master node sends second information to the slave node; orif the master node fails to detect the second time synchronizationtraining, the master node sends second primary synchronizationinformation to the slave node; and correspondingly, the slave nodereceives the second information, or the slave node receives the secondprimary synchronization information.

The second information is used to indicate the moment T4.

In some embodiments, the primary synchronization response message may beused to indicate, to the slave node, that detection of the secondsynchronization sequence fails. After receiving the second primarysynchronization information, the slave node may consider T3 as invaliddata.

S808. The slave node calculates a delay and a time offset between themaster node and the slave node based on T1 to T4, for timesynchronization between the master node and the slave node.

In this embodiment, time synchronization is performed between the masternode and the slave node by sending the first synchronization sequenceand the second synchronization sequence, and the moments T2 and T4 ofreceiving the synchronization sequences are determined when thesynchronization sequences are in quantized forms. Therefore, in theforegoing time intervals, or in other words, in an interval from T1 toT2 and an interval from T3 to T4, relatively few types of signalprocessing are performed on the synchronization sequences, so that delayuncertainty caused by different signal processing can be reduced,thereby improving precision of time synchronization.

Further, the master node sends the first primary synchronizationinformation to the slave node, to instruct the slave node to triggerdetection of the first synchronization sequence, so that the slave nodemay perform detection in the time window, instead of continuouslyperforming detection, thereby improving efficiency of detecting thefirst synchronization sequence.

The time synchronization method and apparatus in the embodiments of thisapplication are described above in detail with reference to FIG. 1 toFIG. 8, and the following continues to describe an apparatus accordingto an embodiment of this application with reference to the accompanyingdrawings.

FIG. 9 is a schematic block diagram of a node 900 according to anembodiment of this application. It should be understood that the node900 can perform steps that are performed by a slave node in FIG. 1 toFIG. 8. To avoid repetition, details are not described herein again. Thenode 900 includes a processing unit 901 and a communications unit 902.The processing unit 901 is configured to: receive a first signal from amaster node by using the communications unit 902, where the first signalincludes a first synchronization sequence; sample the first signal, toobtain a first sample; quantize the first sample, to obtain a quantizedform of the first sample; detect the first synchronization sequence fromthe quantized form of the first sample, where a moment of detecting thefirst synchronization sequence is T2; receive first information from themaster node by using the communications unit 902, where the firstinformation is used to indicate a moment T1 at which the master nodesends the first synchronization sequence; send a second synchronizationsequence to the master node by using the communications unit 902, wherea moment of sending the second synchronization sequence is T3; receivesecond information from the master node by using the communications unit902, where the second information is used to indicate a moment T4 atwhich the master node detects a quantized form of the secondsynchronization sequence; and perform time synchronization between theslave node and the master node based on T1, T2, T3, and T4.

FIG. 10 is a schematic block diagram of a node 1000 according to anembodiment of this application. It should be understood that the node1000 can perform steps that are performed by a master node in FIG. 1 toFIG. 8. To avoid repetition, details are not described herein again. Thenode 1000 includes a processing unit 1001 and a communications unit1002. The processing unit 1001 is configured to send a first signal to aslave node by using the communications unit 1002, where the first signalincludes a first synchronization sequence; send first information to theslave node by using the communications unit 1002, where the firstinformation is used to indicate a moment T1 at which the master nodesends the first synchronization sequence; receive a second signal fromthe slave node by using the communications unit 1002, where the secondsignal includes a second synchronization sequence; sample the secondsignal, to obtain a third sample; quantize the third sample, to obtain aquantized form of the third sample; detect the second synchronizationsequence from the quantized form of the third sample, where a moment ofdetecting the second synchronization sequence is T4; and send secondinformation to the slave node by using the communications unit 1002,where the second information is used to indicate T4, and T1 and T4 areused for time synchronization between the master node and the slavenode.

FIG. 11 is a schematic structural diagram of a node 1100 according to anembodiment of this application. As shown in FIG. 11, the node 1100includes one or more processors 1130, one or more memories 1110, and oneor more communications interfaces 1120. The processor 1130 is configuredto control the communications interface 1120 to receive and sendsignals, and the memory 1110 is configured to store a computer program.The processor 1130 is configured to invoke the computer program from thememory 1110, and run the computer program, so that the node 1100performs a corresponding procedure and/or operation performed by a slavenode in the time synchronization method embodiment in this application.For brevity, details are not described herein.

It should be noted that the node 900 shown in FIG. 9 may be implementedby the node 1100 shown in FIG. 11. For example, the communications unit901 may be implemented by the communications interface 1120 in FIG. 11.The processing unit 901 may be implemented by the processor 1130.

FIG. 12 is a schematic structural diagram of a node 1200 according to anembodiment of this application. As shown in FIG. 12, the node 1200includes one or more processors 1230, one or more memories 1210, and oneor more communications interfaces 1220. The processor 1230 is configuredto control the communications interface 1220 to receive and sendsignals, and the memory 1210 is configured to store a computer program.The processor 1230 is configured to invoke the computer program from thememory 1210, and run the computer program, so that the node 1200performs a corresponding procedure and/or operation performed by amaster node in the time synchronization method embodiment in thisapplication. For brevity, details are not described herein.

It should be noted that the node 1000 shown in FIG. 10 may beimplemented by the node 1200 shown in FIG. 12. For example, thecommunications unit 1001 may be implemented by the communicationsinterface 1220 in FIG. 12. The processing unit 1001 may be implementedby the processor 1230.

A person of ordinary skill in the art may be aware that, in combinationwith the examples described in the embodiments disclosed in thisspecification, units and algorithm steps may be implemented byelectronic hardware or a combination of computer software and electronichardware. Whether the functions are performed by hardware or softwaredepends on particular applications and design constraint conditions ofthe technical solutions. A person skilled in the art may use differentmethods to implement the described functions for each particularapplication, but it should not be considered that the implementationgoes beyond the scope of this application.

It may be clearly understood by a person skilled in the art that, forthe purpose of convenient and brief description, for a detailed workingprocess of the foregoing system, apparatus, and unit, reference may bemade to a corresponding process in the foregoing method embodiments, anddetails are not described herein again.

In the several embodiments provided herein, it should be understood thatthe disclosed system, apparatus, and method may be implemented in othermanners. For example, the described apparatus embodiment is merely anexample. For example, the unit division is merely logical functiondivision and may be other division in actual implementation. Forexample, a plurality of units or components may be combined orintegrated into another system, or some features may be ignored or notperformed. In addition, the displayed or discussed mutual couplings ordirect couplings or communication connections may be implemented byusing some interfaces. The indirect couplings or communicationconnections between the apparatuses or units may be implemented inelectronic, mechanical, or other forms.

The units described as separate parts may or may not be physicallyseparate, and parts displayed as units may or may not be physical units,may be located in one position, or may be distributed on a plurality ofnetwork units. Some or all of the units may be selected based on actualrequirements to achieve the objectives of the solutions of theembodiments.

In addition, functional units in the embodiments of this application maybe integrated into one processing unit, or each of the units may existalone physically, or two or more units are integrated into one unit.

When the functions are implemented in the form of a software functionalunit and sold or used as an independent product, the functions may bestored in a computer-readable storage medium. Based on such anunderstanding, the technical solutions of this application essentially,or the part contributing to the prior art, or some of the technicalsolutions may be implemented in a form of a software product. Thesoftware product is stored in a storage medium, and includes severalinstructions for instructing a computer device (which may be a personalcomputer, a server, or a network device) to perform all or some of thesteps of the methods described in the embodiments of this application.The foregoing storage medium includes: any medium that can store programcode, such as a USB flash drive, a removable hard disk, a read-onlymemory (ROM), a random access memory (RAM), a magnetic disk, or anoptical disc.

The foregoing descriptions are merely specific implementations of thisapplication, but are not intended to limit the protection scope of thisapplication. Any variation or replacement readily figured out by aperson skilled in the art within the technical scope disclosed in thisapplication shall fall within the protection scope of this application.Therefore, the protection scope of this application shall be subject tothe protection scope of the claims.

What is claimed is:
 1. A time synchronization method, comprising:receiving, by a slave node, a first signal from a master node, whereinthe first signal comprises a first synchronization sequence; sampling,by the slave node, the first signal, to obtain a first sample;quantizing, by the slave node, the first sample, to obtain a quantizedform of the first sample; detecting, by the slave node, the firstsynchronization sequence from the quantized form of the first sample,wherein a moment of detecting the first synchronization sequence is T2;receiving, by the slave node, first information from the master node,wherein the first information indicates a moment T1 at which the masternode sends the first synchronization sequence; sending, by the slavenode, a second synchronization sequence to the master node, wherein amoment of sending the second synchronization sequence is T3; receiving,by the slave node, second information from the master node, wherein thesecond information indicates a moment T4 at which the master nodedetects a quantized form of the second synchronization sequence; andperforming, by the slave node, time synchronization between the slavenode and the master node based on T1, T2, T3, and T4.
 2. The methodaccording to claim 1, wherein detecting, by the slave node, the firstsynchronization sequence from the quantized form of the first samplecomprises: performing, by the slave node, correlation peak detection ofthe first synchronization sequence on the quantized form of the firstsample.
 3. The method according to claim 1, wherein the first signalfurther comprises a third synchronization sequence used for groupsynchronization, and a first offset exists between a first element ofthe third synchronization sequence and a first element of the firstsynchronization sequence; and detecting, by the slave node, the firstsynchronization sequence from the quantized form of the first samplecomprises: determining, by the slave node, a first location, wherein thefirst location is a location of the first element of the thirdsynchronization sequence in the quantized form of the first sample;determining, by the slave node, a second location based on the firstlocation and the first offset, wherein the second location is a locationof the first element of the first synchronization sequence in thequantized form of the first sample; obtaining, by the slave node, aquantized form of a second sample based on the second location, whereinthe first sample comprises the second sample; and detecting, by theslave node, the first synchronization sequence from the quantized formof the second sample.
 4. The method according to claim 3, whereindetermining, by the slave node, a the first location comprises:performing, by the slave node, correlation peak detection of the thirdsynchronization sequence on the quantized form of the first sample, todetermine the first location; and detecting, by the slave node, thefirst synchronization sequence from the quantized form of the secondsample comprises: performing, by the slave node, correlation peakdetection of the first synchronization sequence on the quantized form ofthe second sample.
 5. The method according to claim 1, wherein sending,by the slave node, the second synchronization sequence to the masternode comprises: generating, by the slave node, an encoded codeword;inserting, by the slave node, the second synchronization sequence intothe encoded codeword, wherein a moment of inserting the secondsynchronization sequence is T3; processing, by the slave node, theencoded codeword into which the second synchronization sequence isinserted, to generate a second signal; and sending, by the slave node,the second signal to the master node.
 6. The method according to claim5, wherein the method further comprises: inserting, by the slave nodeinto the encoded codeword, a fourth synchronization sequence used forgroup synchronization, wherein a second offset exists between a firstelement of the fourth synchronization sequence and a first element ofthe second synchronization sequence.
 7. A time synchronization method,comprising: sending, by a master node, a first signal to a slave node,wherein the first signal comprises a first synchronization sequence;sending, by the master node, first information to the slave node,wherein the first information indicates a moment T1 at which the masternode sends the first synchronization sequence; receiving, by the masternode, a second signal from the slave node, wherein the second signalcomprises a second synchronization sequence; sampling, by the masternode, the second signal, to obtain a third sample; quantizing, by themaster node, the third sample, to obtain a quantized form of the thirdsample; detecting, by the master node, the second synchronizationsequence from the quantized form of the third sample, wherein a momentof detecting the second synchronization sequence is T4; and sending, bythe master node, second information to the slave node, wherein thesecond information indicates T4, and T1 and T4 are used for timesynchronization between the master node and the slave node.
 8. Themethod according to claim 7, wherein detecting, by the master node, thesecond synchronization sequence from the quantized form of the thirdsample comprises: performing, by the master node, correlation peakdetection of the second synchronization sequence on the quantized formof the third sample.
 9. The method according to claim 7, wherein thesecond signal further comprises a fourth synchronization sequence usedfor group synchronization, and a second offset exists between a firstelement of the fourth synchronization sequence and a first element ofthe second synchronization sequence; and detecting, by the master node,the second synchronization sequence from the quantized form of the thirdsample comprises: determining, by the master node, a third location,wherein the third location is a location of the first element of thefourth synchronization sequence in the quantized form of the thirdsample; determining, by the master node, a fourth location based on thethird location and the second offset, wherein the fourth location is alocation of the first element of the second synchronization sequence inthe quantized form of the third sample; obtaining, by the master node, aquantized form of a fourth sample based on the fourth location, whereinthe third sample comprises the fourth sample; and detecting, by themaster node, the second synchronization sequence from the quantized formof the fourth sample.
 10. The method according to claim 9, whereindetermining, by the master node, the third location comprises:performing, by the master node, correlation peak detection of the fourthsynchronization sequence on the quantized form of the third sample, todetermine the third location; and detecting, by the master node, thesecond synchronization sequence from the quantized form of the fourthsample comprises: performing, by the master node, correlation peakdetection of the second synchronization sequence on the quantized formof the fourth sample.
 11. The method according to claim 7, whereinsending, by a master node, the first signal to a slave node comprises:generating, by the master node, an encoded codeword; inserting, by themaster node, the first synchronization sequence into the encodedcodeword, wherein a moment of inserting the first synchronizationsequence is T1; processing, by the master node, the encoded codewordinto which the first synchronization sequence is inserted, to generatethe first signal; and sending, by the master node, the first signal tothe slave node.
 12. The method according to claim 11, wherein the methodfurther comprises: inserting, by the master node into the encodedcodeword, a third synchronization sequence used for groupsynchronization, wherein a first offset exists between a first elementof the third synchronization sequence and a first element of the firstsynchronization sequence.
 13. A node, comprising: a memory configured tostore a computer program instruction; and a processor coupled to thememory, wherein the computer program instruction causes the processor tobe configured to: receive a first signal from a master node, wherein thefirst signal comprises a first synchronization sequence; sample thefirst signal, to obtain a first sample; quantize the first sample, toobtain a quantized form of the first sample; detect the firstsynchronization sequence from the quantized form of the first sample,where a moment of detecting the first synchronization sequence is T2;receive first information from the master node, wherein the firstinformation indicates a moment T1 at which the master node sends thefirst synchronization sequence; send a second synchronization sequenceto the master node, wherein a moment of sending the secondsynchronization sequence is T3; and receive second information from themaster node, wherein the second information is used to indicate a momentT4 at which the master node detects a quantized form of the secondsynchronization sequence; and perform time synchronization between theslave node and the master node based on T1, T2, T3, and T4.
 14. The nodeaccording to claim 13, wherein the computer program instruction furthercauses the processor to be configured to: perform correlation peakdetection of the first synchronization sequence on the quantized form ofthe first sample.
 15. The node according to claim 13, wherein the firstsignal further comprises a third synchronization sequence used for groupsynchronization, and a first offset exists between a first element ofthe third synchronization sequence and a first element of the firstsynchronization sequence; and wherein the computer program instructionfurther causes the processor to be configured to: determine a firstlocation, wherein the first location is a location of the first elementof the third synchronization sequence in the quantized form of the firstsample; determine a second location based on the first location and thefirst offset, wherein the second location is a location of the firstelement of the first synchronization sequence in the quantized form ofthe first sample; obtain a quantized form of a second sample based onthe second location, wherein the first sample comprises the secondsample; and detect the first synchronization sequence from the quantizedform of the second sample.
 16. The node according to claim 15, whereinthe computer program instruction further causes the processor to beconfigured to: perform correlation peak detection of the thirdsynchronization sequence on the quantized form of the first sample, todetermine the first location; and perform correlation peak detection ofthe first synchronization sequence on the quantized form of the secondsample.
 17. The node according to claim 13, wherein the computer programinstruction further causes the processor to be configured to: generatean encoded codeword; insert the second synchronization sequence into theencoded codeword, wherein a moment of inserting the secondsynchronization sequence is T3; process the encoded codeword into whichthe second synchronization sequence is inserted, to generate a secondsignal; and send, by the slave node, the second signal to the masternode.
 18. The node according to claim 17, wherein the computer programinstruction further causes the processor to be configured to: insert afourth synchronization sequence used for group synchronization, whereina second offset exists between a first element of the fourthsynchronization sequence and a first element of the secondsynchronization sequence.